package servlet;

import pojo.CurriCulum;
import service.LogicService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

/**
 * 2022.03.17测试完成 由吴俊莹编写完成
 */
@WebServlet(name = "/DeleteServlet",value = "/DeleteServlet")
public class DeleteServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=UTF-8");

        LogicService logic=new LogicService();
        int x=0;
        CurriCulum curriCulum=new CurriCulum();
        curriCulum.setId(Integer.parseInt(req.getParameter("id")));
        curriCulum.setInvalid(Integer.parseInt(req.getParameter("shi")));
        try {
            x=logic.DelUesr_Up(curriCulum);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        PrintWriter out=resp.getWriter();
        out.print(x);
    }
}
